package com.acme;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AwardWinnerListAdapter extends ArrayAdapter<AwardWinner> {
	
	public AwardWinnerListAdapter(Context context, int textViewResourceId, AwardWinner[] winners) {
		super(context, textViewResourceId, winners);
		Log.i("PlayerListAdapter", "Constructor");
	}
	
	@Override
    public View getView(int position, View convertView, ViewGroup parent) {
		
            View v = convertView;
            
            if (v == null) {
                LayoutInflater vi = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                //v = vi.inflate(R.layout.player_list_item, null);
                v = vi.inflate(R.layout.winner_list_item, parent, false);
            }
            
            AwardWinner winner = getItem(position);
            if (winner != null) {
            	
            	Log.v("debug",winner.toString());
            	
                TextView year = (TextView) v.findViewById(R.id.year);
                TextView name = (TextView) v.findViewById(R.id.name);
                
                name.setText(winner.firstName+" "+winner.lastName);
                year.setText(winner.year);
            }
            return v;
    }
	
}
